package com.ruoyi.system.service.impl;

import com.ruoyi.system.entity.JobInvolveMonitorPositionConfig;
import com.ruoyi.system.mapper.JobInvolveMonitorPositionConfigMapper;
import com.ruoyi.system.service.JobInvolveMonitorPositionConfigService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 涉及监控点位(JobInvolveMonitorPositionConfig)表服务实现类
 *
 * @author makejava
 * @since 2022-11-25 11:39:06
 */
@Service("jobInvolveMonitorPositionConfigService")
public class JobInvolveMonitorPositionConfigServiceImpl implements JobInvolveMonitorPositionConfigService {
    @Resource
    private JobInvolveMonitorPositionConfigMapper jobInvolveMonitorPositionConfigDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public JobInvolveMonitorPositionConfig queryById(Integer id) {
        return this.jobInvolveMonitorPositionConfigDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param jobInvolveMonitorPositionConfig 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<JobInvolveMonitorPositionConfig> queryByPage(JobInvolveMonitorPositionConfig jobInvolveMonitorPositionConfig, PageRequest pageRequest) {
        long total = this.jobInvolveMonitorPositionConfigDao.count(jobInvolveMonitorPositionConfig);
        return new PageImpl<>(this.jobInvolveMonitorPositionConfigDao.queryAllByLimit(jobInvolveMonitorPositionConfig, pageRequest), pageRequest, total);
    }

    @Override
    public List<JobInvolveMonitorPositionConfig> queryAll(JobInvolveMonitorPositionConfig jobInvolveMonitorPositionConfig) {
        return jobInvolveMonitorPositionConfigDao.queryAll(jobInvolveMonitorPositionConfig);
    }

    /**
     * 新增数据
     *
     * @param jobInvolveMonitorPositionConfig 实例对象
     * @return 实例对象
     */
    @Override
    public JobInvolveMonitorPositionConfig insert(JobInvolveMonitorPositionConfig jobInvolveMonitorPositionConfig) {
        this.jobInvolveMonitorPositionConfigDao.insert(jobInvolveMonitorPositionConfig);
        return jobInvolveMonitorPositionConfig;
    }

    /**
     * 修改数据
     *
     * @param jobInvolveMonitorPositionConfig 实例对象
     * @return 实例对象
     */
    @Override
    public JobInvolveMonitorPositionConfig update(JobInvolveMonitorPositionConfig jobInvolveMonitorPositionConfig) {
        this.jobInvolveMonitorPositionConfigDao.update(jobInvolveMonitorPositionConfig);
        return this.queryById(jobInvolveMonitorPositionConfig.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.jobInvolveMonitorPositionConfigDao.deleteById(id) > 0;
    }
}
